﻿@model Shop.Order.Models.Courier
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ex</title>
    <link href="~/Content/BootStrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/docs.min.css" rel="stylesheet" />
    <link href="~/bootstrapvalidator-master/dist/css/bootstrapValidator.min.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/BootStrap/js/bootstrap.min.js"></script>
    <script src="~/Content/BootStrap/js/docs.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/bootstrapValidator.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/language/zh_CN.js"></script>

    @*上传*@
    <script src="~/bootstrap-fileinput-master/js/fileinput.min.js"></script>
    <script src="~/bootstrap-fileinput-master/js/locales/zh.js"></script>
    <link href="~/bootstrap-fileinput-master/css/fileinput.min.css" rel="stylesheet" />
</head>
<body>
    <div style="margin-top:145px;margin-left:170px">
        <a href="~/down/moban.rar" >下载模板</a>
    </div>
    <form id="form_Upload" method="post" class="form-horizontal" action="Browse" enctype="multipart/form-data" style="margin-top:10px;display:block">
        @Html.AntiForgeryToken() @*防止跨站请求伪造(CSRF:Cross-site request forgery)攻击*@
        <div class="form-group">
            <label class="col-lg-2 control-label" for="Url">快递单导入</label>
            <div class="col-lg-4">
                <input id="file" name="file" type="file" class="file-loading" multiple data-show-caption="true">
            </div>
        </div>
        <div class="form-group">
            <div class="col-lg-2"></div>
            <input type="button" value="验证文件准确性" class="btn btn-primary" onclick="yz()" />
        </div>
    </form>
    @if (ViewBag.PanDuan == 0 || ViewBag.Data == null)
    {
        <input type="button" class="btn btn-primary" value="开始导入" disabled style="margin-left:245px"/>
    }
    @if (ViewBag.PanDuan == 1 && ViewBag.Data != null)
    {
        <form method="post" class="form-horizontal" action="AddCourier"  enctype="multipart/form-data" style="margin-left:245px">
            <input type="text" hidden="hidden" value="@ViewBag.VCourier" id="VCourier" name="VCourier"/>
            <input type="submit" class="btn btn-primary" value="开始导入" />
        </form>
        
    }
    @if(ViewBag.PanDuan == 2)
    {
        <table class="table  table-striped  table-hover table-bordered" style="color:red;">
            <tr>
                <th colspan="2">存在重复单号请检查后重新导入</th>
            </tr>
            <tr>
                <th>重复单号:</th>
                <th>@ViewBag.DanHao</th>
            </tr>
        </table>

    }
    @if (ViewBag.PanDuan == 0)
    {
        <table class="table  table-striped  table-hover table-bordered" style="color:red;">
            <tr>
                <th colspan="2">以下容存在错误,请检查是否当前单号重复</th>
            </tr>
            <tr>
                <th>快递公司</th>
                <th>快递单号</th>
            </tr>
            @if (ViewBag.Data != null)
            {
                foreach (var item in (ViewBag.Data as IEnumerable<Shop.Order.Models.Courier>))
                {
                    <tr>
                        <td>@Html.DisplayFor(model => item.CCode)</td>
                        <td>@Html.DisplayFor(model => item.CourierNumber)</td>
                    </tr>
                }
            }
        </table>
    }
    @if (ViewBag.PanDuan == 1)
    {
        <table class="table  table-striped  table-hover table-bordered">
            <tr>
                <th colspan="2">数据预览</th>
            </tr>
            <tr>
                <th>快递公司</th>
                <th>快递单号</th>
            </tr>
            @if (ViewBag.Data != null)
            {
                //生成前10条数据 填充表格table
                foreach (var item in (ViewBag.Data as IEnumerable <Shop.Order.Models.Courier>))
                {
                    <tr>
                        <td>@Html.DisplayFor(model => item.CCode)</td>
                        <td>@Html.DisplayFor(model => item.CourierNumber)</td>
                    </tr>
                }
            }
        </table>
    }
    <script type="text/javascript">
        function yz() {
            var data = $('#file').val();
            if (data == "") {
                alert("请选择正确的文件");
            }
            else {
                $('#form_Upload').submit();
            }
        }
        $(document).on('ready', function () {
            $("#file").fileinput({
                language: 'zh', //设置语言
                uploadUrl: "", //上传的地址
                allowedFileExtensions: ['xlsx'],//接收的文件后缀
                showUpload: false, //是否显示上传按钮
                showCaption: false,//是否显示标题
                showPreview: false,
                browseClass: "btn btn-primary", //按钮样式
                previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
                maxFileSize: 10000,
            });
        });
    </script>
    <script type="text/javascript">
        $('input[id=fileUpload]').change(function () {
            $('#txt_Path').val($(this).val());
            $('#form_Upload').submit();
        });
    </script>
</body>



</html>
